import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class FighterMidlet extends MIDlet implements CommandListener {
  private FighterCanvas fighterCanvas;

  public void startApp() {
        if (fighterCanvas == null){
            fighterCanvas = new FighterCanvas();
            fighterCanvas.start();
            Command exitCommand = new Command("Exit", Command.EXIT, 0);
            fighterCanvas.addCommand(exitCommand);
            fighterCanvas.setCommandListener(this);
        }

    Display.getDisplay(this).setCurrent(fighterCanvas);
  }
  public void pauseApp() {}


  public void destroyApp(boolean unconditional) {
    if (fighterCanvas != null)
      fighterCanvas.stop();
  }

  public void commandAction(Command c, Displayable s) {
    if (c.getCommandType() == Command.EXIT) {
      destroyApp(true);
      notifyDestroyed();
    }
  }
}